package com.unohacha.qqj.fzdr.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lzy.ninegrid.ImageInfo;
import com.lzy.ninegrid.NineGridView;
import com.lzy.ninegrid.preview.NineGridViewClickAdapter;
import com.unohacha.qqj.fzdr.R;
import com.unohacha.qqj.fzdr.bean.SupplyMatchModel;

import java.util.ArrayList;
import java.util.List;

public class AfterPubAdapter extends BaseQuickAdapter<SupplyMatchModel.DataBeanX.DataBean, BaseViewHolder> {
    public AfterPubAdapter(List<SupplyMatchModel.DataBeanX.DataBean> data) {
        super(R.layout.item_pub_after_match, data);

    }

    @Override
    protected void convert(final BaseViewHolder helper, final SupplyMatchModel.DataBeanX.DataBean pubMatchData) {
        Glide.with(mContext).load(pubMatchData.getMember_thumb()).into((ImageView) helper.getView(R.id.store_logo_iv));
        helper.setText(R.id.store_name_tv,pubMatchData.getMember_no());
        helper.setText(R.id.store_report_content,pubMatchData.getTitle());
        helper.setText(R.id.report_time_tv,pubMatchData.getCreate_time());
        helper.setText(R.id.comment_num_tv,pubMatchData.getCommon_nums() + "评论");
        helper.setText(R.id.look_num_tv,pubMatchData.getHits() + "浏览");
        helper.setText(R.id.collect_num_tv,pubMatchData.getCollection_nums() + "收藏");

        helper.addOnClickListener(R.id.look_more);

        //九宫格展示
        ArrayList<ImageInfo> imageInfo = new ArrayList<>();
        List<String> imageDetails = pubMatchData.getList_pic();
        if (imageDetails != null) {
            for (String imageDetail : imageDetails) {
                ImageInfo info = new ImageInfo();
                info.setThumbnailUrl(imageDetail);
                info.setBigImageUrl(imageDetail);
                imageInfo.add(info);
            }
        }
        NineGridView nineGridView = helper.getView(R.id.item_release_rv_picture);

        nineGridView.setAdapter(new NineGridViewClickAdapter(mContext, imageInfo));
    }

}
